package com.cec.controller.admin;


import com.cec.dto.CategoryDTO;
import com.cec.service.admin.ActivityService;
import com.cec.dto.ActivityDTO;
import com.cec.entity.Activity;
import com.cec.result.Result;
import com.cec.vo.CategoryVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 活动表 前端控制器
 * </p>
 *
 * @author lt
 * @since 2024-10-25
 */
@Slf4j
@RestController
@RequestMapping("/admin/activity")
public class ActivityController {
    @Autowired
    private ActivityService activityService;
    @GetMapping
    @ResponseBody
    @ApiOperation("分页查询")
    public Result pageQueryActivity(ActivityDTO activityDTO){
        log.info("activityDTO-->{}",activityDTO);
        //return activityService.pageQueryActivityList(activityDTO);
        return activityService.pageQueryActivityList(activityDTO);
    }

    @PostMapping
    @ApiOperation("添加活动信息")
    public Result saveActivity(@RequestBody ActivityDTO activityDTO) {
        log.info("activityDTO-->{}",activityDTO);

        return activityService.saveActivity(activityDTO);
    }

    @PutMapping
    @ApiOperation("修改活动信息")
    public Result updateActivity(@RequestBody ActivityDTO activityDTO) {
        log.info("activityDTO-->{}",activityDTO);

        return activityService.updateActivity(activityDTO);
    }

    @GetMapping("/{id}")
    @ApiOperation("通过id查询活动信息")
    public Result queryActivityById(@PathVariable Long id){
        log.info("id-->{}",id);
        Activity activity = activityService.queryActivityById(id);
        return Result.success(activity);
    }

    @GetMapping("/type")
    @ApiOperation("查询活动分类")
    public Result queryActivityType(CategoryDTO categoryDTO){
        return activityService.queryActivityType(categoryDTO);
    }

    @DeleteMapping("/logicDel/{id}")
    @ApiOperation("逻辑删除志愿者信息")
    public Result logicDeleteActivityById(@PathVariable Integer id){
        log.info("id-->{}",id);
        return activityService.logicDeleteActivityById(id);
    }

    @DeleteMapping("/logicBatchDel")
    @ApiOperation("逻辑批量删除志愿者信息")
    public Result logicBatchDeleteActivityByIds(@RequestBody List<Integer> ids){
        log.info("id-->{}",ids);
        return activityService.logicBatchDeleteActivityByIds(ids);
    }
}

